#ifndef __LINKTREE_H_
#define __LINKTREE_H_
#define ElementType struct UniversalType
#include<stdio.h>
#include<stdlib.h>

enum Type
{
    charPoint,
    intPoint,
    structPoint
};


struct UniversalType
{
    void * value;
    enum Type type;
};


struct LinkTreeNode
{
    ElementType data;
    struct LinkTreeNode *firstChild;
    struct LinkTreeNode *nextSibling;
    struct LinkTreeNode *parent;
};


typedef struct LinkTreeNode LTNode;
LTNode *CreateTreeNode(ElementType element);
void ConnectBranch(LTNode *parent,LTNode *child);
void DisConnectBranch(LTNode *parent,LTNode *child);
LTNode *FindNode(LTNode *node,ElementType element, int (*func)(ElementType,ElementType));
void FreeNode(LTNode* treeNode);


struct LinkTree
{
    LTNode *root;
};
typedef struct LinkTree LTree; 


int InitLTree(LTree *tree);
void FreeTree(LTree *tree);
int GetTreeHeight(LTree *tree);
LTNode* FindTreeNode(LTree *tree,ElementType element,int (*func)(ElementType,ElementType));
void Travel(LTree *tree,void(*func)(ElementType ));


#endif